#include <bits/stdc++.h>
using namespace std;

int n,a[100010],cnt[100010],sum = 1,cntt = 0,f1 = 0,f2 = 0;

bool vis[100010];

int main()
{
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    cin >> n;
    bool flag = 1;
    for(int i = 1;i <= n;i++)
    {
        cin >> a[i];
        if(vis[a[i]])
        {
            flag = 0;
        }
        else
        {
            vis[a[i]] = 1;
        }
        if(a[i] == 1)
        {
            f1++;
        }
        if(a[i] ==  2)
        {
            f2++;
        }
    }
    if(flag)
    {
        cout << 1;
        return 0;
    }
    if(f1 + f2 == n)
    {
        cout << max(f1,f2);
        return 0;
    }
    sort(a + 1,a + n + 1);
    /*for(int i = 1;i <= n;i++)
    {
        cout << a[i] << " ";
    }
    cout << endl;*/
    for(int i = 2;i <= n;i++)
    {
        if(a[i] > a[i - 1])
        {
            //cout << sum << endl;
            cnt[++cntt] = sum;
            sum = 0;
        }
        sum++;
    }
    if(sum)
    {
        cnt[++cntt] = sum;
        sum = 0;
    }
    /*for(int i = 1;i <= cntt;i++)
    {
        cout << cnt[i] << " ";
    }*/
    for(int i = 2;i <= cntt;i++)
    {
        sum += (cnt[i - 1] == cnt[i] ? cnt[i] : (cnt[i - 1] > cnt[i] ? cnt[i] : cnt[i - 1]));
    }
    cout << n - sum << endl;
    return 0;
}
